1   package com.iluwatar;
2   
3   /**
4    * 
5    * Concrete factory class.
6    * 
7    */
8   public class HeroFactoryImpl implements HeroFactory {
9   
10  	private Mage mage;
11  	private Warlord warlord;
12  	private Beast beast;
13  
14  	public HeroFactoryImpl(Mage mage, Warlord warlord, Beast beast) {
15  		this.mage = mage;
16  		this.warlord = warlord;
17  		this.beast = beast;
18  	}
19  
20  	public Mage createMage() {
21  		try {
22  			return mage.clone();
23  		} catch (CloneNotSupportedException e) {
24  			return null;
25  		}
26  	}
27  
28  	public Warlord createWarlord() {
29  		try {
30  			return warlord.clone();
31  		} catch (CloneNotSupportedException e) {
32  			return null;
33  		}
34  	}
35  
36  	public Beast createBeast() {
37  		try {
38  			return beast.clone();
39  		} catch (CloneNotSupportedException e) {
40  			return null;
41  		}
42  	}
43  
44  }